home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 4 / CU Amiga Magazine's Super CD-ROM 04 (1996)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1996-11].iso / magazine / psion / new / spydrx.lzx / hebb.web < prev    next >
Text File  |  2011-01-26  |  5KB  |  212 lines

  1.  
  2. <opts>
  3. <isrc>cell</isrc>
  4. <iname>INPUT</iname>
  5. <iecho>no</iecho>
  6. <odest>screen</odest>
  7. <oname>OUTPUT</oname>
  8. <onewl>lf</onewl>
  9. <scrfont>swiss11</scrfont>
  10. <statwin>off</statwin>
  11. <cfmt></cfmt>
  12. <citer>1</citer>
  13. <cdisp>nolist</cdisp>
  14. <rtype>fmt</rtype>
  15. <rfmt>\n\N:=\F</rfmt>
  16. <rall>yes</rall>
  17. <starg></starg>
  18. <srpl></srpl>
  19. <scount>1</scount>
  20. <sout>yes</sout>
  21. <nfmt>fixed</nfmt>
  22. <ndec>1</ndec>
  23. <nang>degrees</nang></opts>
  24. <cell>
  25. <cname>a1</cname>
  26. <val>2</val></cell>
  27. <cell>
  28. <cname>a2</cname>
  29. <val>3</val></cell>
  30. <cell>
  31. <cname>a3</cname>
  32. <val>8</val></cell>
  33. <cell>
  34. <cname>a4</cname>
  35. <val>6</val></cell>
  36. <cell>
  37. <cname>b1</cname>
  38. <val>4.0</val>
  39. <script>a1*w11+a2*w21+a3*w31+a4*w41</script></cell>
  40. <cell>
  41. <cname>b2</cname>
  42. <val>3.0</val>
  43. <script>a1*w12+a2*w22+a3*w32+a4*w42</script></cell>
  44. <cell>
  45. <cname>b3</cname>
  46. <val>2.0</val>
  47. <script>a1*w13+a2*w23+a3*w33+a4*w43</script></cell>
  48. <cell>
  49. <cname>b4</cname>
  50. <val>1.0</val>
  51. <script>a1*w14+a2*w24+a3*w34+a4*w44</script></cell>
  52. <cell>
  53. <cname>computeBs</cname>
  54. <val>1.0</val>
  55. <script>b1! b2! b3! b4!</script></cell>
  56. <cell>
  57. <cname>computeWs</cname>
  58. <val>0.1</val>
  59. <script> w11! w12! w13! w14! w21! w22! w23! w24! w31! w32! w33!
  60.          w34! w41! w42! w43! w44!
  61.  
  62. </script></cell>
  63. <cell>
  64. <cname>home</cname>
  65. <text>This web illustrates Hebbian learning and the use of a delta rule for pattern association between two four element vectors A and B, using an interconnection matrix W.
  66.  
  67.    a1       a2       a3       a4
  68. w11   w12    w13    w15    b1
  69. w21   w22    w23    w24    b2
  70. w31   w32    w33    w34    b3
  71. w41   w42    w43    w44    b4
  72.  
  73. For any collection of weights (wij's) and inputs (aj's), a collection of outputs (bj's) may be computed according to the formula:
  74.  
  75.     1)    bj=a1*w1j+a2*w2j+a3*w3j+a4*w4j,   j=1..4
  76.  
  77. For a given input vector A, it is possible to 'teach' the associator to produce an output vector B, which is arbitrarily close to a target vector T.  This may be done in the following way:
  78.  
  79. a) Set the values aj of the input vector A
  80. b) Set the values ti of the target vector T
  81. (         Steps a) and b) may be done by going to the cell named 'input', setting its text field to the desired row vectors A and T (four a numbers followed by four t numbers),  and selecting execute from the Special menu. )
  82.  
  83. c) Set the formulae of the weights to the expression:
  84.                 wij=wij+ai*(tj-bj)/k         ( delta rule)
  85. ( this has already been done)
  86.  
  87. d)  Set the values of the weights wij to random or
  88.          to similar small values.
  89. ( Position to the cell RandomizeWeights and execute its script to accomplish this task)
  90.  
  91. e) Compute a trial set of output values using equation 1).
  92.  ( Execute the script of cell ComputeBs to perform this computation. )
  93.  
  94. f)  Recompute the weights wij according to the delta rule.
  95. ( Execute the script of cell ComputeWs to recompute the weights )
  96.  
  97. g)  Repet steps e) and f) until the output vector B is as close to the target vector T as you desire.
  98. (Each time it is executed, the script of this 'home' cell will repeat steps e) and f) 25 times, and ouput a comparison between the B vector and T vector.)
  99. </text>
  100. <val>0.1</val>
  101. <script>for(kdex=1 to 25) {
  102.     computeBs!
  103.     computeWs!
  104. out(t1," ~ ",b1,"    ")
  105. out(t2," ~ ",b2,"    ")
  106. out(t3," ~ ",b3,"    ")
  107. out(t4," ~ ",b4,"\n")
  108. } #endfor</script></cell>
  109. <cell>
  110. <cname>idex</cname>
  111. <val>3.0</val></cell>
  112. <cell>
  113. <cname>input</cname>
  114. <text>2,3,8,6            # input vector
  115. 4,3,2,1            # target vector</text>
  116. <script>in(a1,a2,a3,a4)
  117. in(t1,t2,t3,t4)</script></cell>
  118. <cell>
  119. <cname>jdex</cname>
  120. <val>3.0</val></cell>
  121. <cell>
  122. <cname>k</cname>
  123. <val>1000</val></cell>
  124. <cell>
  125. <cname>kdex</cname>
  126. <val>25.0</val></cell>
  127. <cell>
  128. <cname>RandomizeWeights</cname>
  129. <script>for(idex=0 to 3) {
  130.     for(jdex=0 to 3) {
  131.         set w11[4*idex+jdex] to 0.0001*rand()
  132.     } #endfor
  133. } #endfor</script></cell>
  134. <cell>
  135. <cname>t1</cname>
  136. <val>4</val></cell>
  137. <cell>
  138. <cname>t2</cname>
  139. <val>3</val></cell>
  140. <cell>
  141. <cname>t3</cname>
  142. <val>2</val></cell>
  143. <cell>
  144. <cname>t4</cname>
  145. <val>1</val></cell>
  146. <cell>
  147. <cname>train</cname>
  148. <script>in(t1,t2,t3,t4)</script></cell>
  149. <cell>
  150. <cname>w11</cname>
  151. <val>0.1</val>
  152. <script>w11+a1*(t1-b1)/k</script></cell>
  153. <cell>
  154. <cname>w12</cname>
  155. <val>0.1</val>
  156. <script>w12+a1*(t2-b2)/k</script></cell>
  157. <cell>
  158. <cname>w13</cname>
  159. <val>0.0</val>
  160. <script>w13+a1*(t3-b3)/k</script></cell>
  161. <cell>
  162. <cname>w14</cname>
  163. <val>-0.0</val>
  164. <script>w14+a1*(t4-b4)/k</script></cell>
  165. <cell>
  166. <cname>w21</cname>
  167. <val>0.1</val>
  168. <script>w21+a2*(t1-b1)/k</script></cell>
  169. <cell>
  170. <cname>w22</cname>
  171. <val>0.1</val>
  172. <script>w22+a2*(t2-b2)/k</script></cell>
  173. <cell>
  174. <cname>w23</cname>
  175. <val>0.1</val>
  176. <script>w23+a2*(t3-b3)/k</script></cell>
  177. <cell>
  178. <cname>w24</cname>
  179. <val>-0.0</val>
  180. <script>w24+a2*(t4-b4)/k</script></cell>
  181. <cell>
  182. <cname>w31</cname>
  183. <val>0.3</val>
  184. <script>w31+a3*(t1-b1)/k</script></cell>
  185. <cell>
  186. <cname>w32</cname>
  187. <val>0.2</val>
  188. <script>w32+a3*(t2-b2)/k</script></cell>
  189. <cell>
  190. <cname>w33</cname>
  191. <val>0.1</val>
  192. <script>w33+a3*(t3-b3)/k</script></cell>
  193. <cell>
  194. <cname>w34</cname>
  195. <val>0.1</val>
  196. <script>w34+a3*(t4-b4)/k</script></cell>
  197. <cell>
  198. <cname>w41</cname>
  199. <val>0.2</val>
  200. <script>w41+a4*(t1-b1)/k</script></cell>
  201. <cell>
  202. <cname>w42</cname>
  203. <val>0.2</val>
  204. <script>w42+a4*(t2-b2)/k</script></cell>
  205. <cell>
  206. <cname>w43</cname>
  207. <val>0.1</val>
  208. <script>w43+a4*(t3-b3)/k</script></cell>
  209. <cell>
  210. <cname>w44</cname>
  211. <val>0.1</val>
  212. <script>w44+a4*(t4-b4)/k</script></cell></eof>